<?php
namespace app\backstage\logic;
class Setting
{
    /*获取信息*/
    public function getInfo($where = [])
    {
        $field      = 'id,type,data';
        $Setting    = \think\facade\App::model('Setting');
        $list       = $Setting->getAllList($where,$field);

        return $list;
    }

    /*更新信息*/
    public function editInfo($data)
    {
        $Setting = \think\facade\App::model('Setting');

        foreach ($data as $v){
            $record = $Setting->getOne(['type'=>$v['type']]);
            if($record){
                $Setting->updateRecord(['type'=>$v['type']], ['data'=>$v['data']]);
            }else{
                $Setting->insertRecord(['type'=>$v['type'], 'data'=>$v['data']]);
            }
        }

        return ['code'=>100,'msg'=>'操作成功'];
    }

}